//
//  CalibrationAlartView.m
//  INMOTION
//
//  Created by cjg on 2020/4/16.
//  Copyright © 2020 Inmotion. All rights reserved.
//

#import "CalibrationAlartView.h"
#import "KSLanguageManager.h"
#import "NSObject+HUD.h"

@implementation CalibrationAlartView

-(void)awakeFromNib{
    [super awakeFromNib];

    self.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.7];
    self.bgView.backgroundColor = [UIColor whiteColor];
    [self.lookButton setTitle:IMTNewCarLocalizedString(@"prompt_see_operation_guide") forState:(UIControlStateNormal)];
    [self.commitButton setTitle:IMTNewCarLocalizedString(@"activity_change_bt_pwd_btn_text") forState:(UIControlStateNormal)];
    [self.cancleButton setTitle:IMTNewCarLocalizedString(@"dialog_cancel") forState:(UIControlStateNormal)];
}

+ (CalibrationAlartView *)showAlartViewWithTitle:(NSString *)title message:(NSString *)message golook:(CalibrationAlartViewBlock)lookblock commit:(CalibrationAlartViewBlock)commitblock {
    CalibrationAlartView *av = [[[NSBundle mainBundle] loadNibNamed:@"CalibrationAlartView" owner:self options:nil] lastObject];
    av.frame = [UIScreen mainScreen].bounds;
    av.goLookBlock = lookblock;
    av.commitBlock = commitblock;
    av.titleLB.text = title;
    av.messageLB.text = message;
    [[[UIApplication sharedApplication].delegate window] addSubview:av];
    return av;
}

- (void)dismiss {
    [self removeFromSuperview];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self removeFromSuperview];
}

- (IBAction)lookAction:(UIButton *)sender {
    self.goLookBlock();
    [self removeFromSuperview];
}

- (IBAction)cancle:(UIButton *)sender {
    [self removeFromSuperview];
}

- (IBAction)commit:(UIButton *)sender {
    self.commitBlock();
    [self removeFromSuperview];
}

@end
